﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class info : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["id"] != null)
        {
            load();
        }
    }
    void load()
    {
        String sql = "select title,content,channelid from news where newId=" + Request["id"];

        DataTable dt = DB.getDataTable(sql);
        if (dt.Rows.Count > 0)
        {
            content.Text = dt.Rows[0]["content"].ToString();
            NewDao.click(Request["id"]);

            String str = "";
            String sql1 = "select top 1 name,father_id,url,pageLocation from channel where  channel_id=" + dt.Rows[0]["channelid"].ToString();

            DataTable dt1 = DB.getDataTable(sql1);
            if (dt1.Rows.Count > 0)
            {
                if (dt1.Rows[0]["father_id"] != null && Int16.Parse(dt1.Rows[0]["father_id"].ToString()) > 1)
                {
                    String sql11 = "select top 1 name,url,pageLocation from channel where  channel_id=" + dt1.Rows[0]["father_id"];

                    DataTable dt11 = DB.getDataTable(sql11);
                    if (dt11.Rows.Count > 0)
                    {
                        str += "<a href='" + dt11.Rows[0]["url"].ToString() +
                            (dt11.Rows[0]["url"].ToString().IndexOf("?") > -1 ? "&" : "?") + "channel=" +
                            dt11.Rows[0]["pageLocation"].ToString() + "'>" + dt11.Rows[0]["name"].ToString() + "</a>  -> ";
                    }
                }
                str += "<a href='" + dt1.Rows[0]["url"].ToString() +
                    (dt1.Rows[0]["url"].ToString().IndexOf("?") > -1 ? "&" : "?") + "channel=" +
                    dt1.Rows[0]["pageLocation"].ToString() + "'>" + dt1.Rows[0]["name"].ToString() + "</a>  -> ";
            }
            str += dt.Rows[0]["title"].ToString();
            this.title.Text = str;
        }
    }
}
